package com.dragandjuric.lse.boncote.tapestry.pages;

import org.apache.tapestry5.Block;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.dragandjuric.lse.boncote.Person;
import com.dragandjuric.lse.boncote.beans.PersonBean;
import com.dragandjuric.lse.boncote.service.Persons;

public class AddPerson {

	@Property
	@Inject
	private Block edit;
	
	@Property
	@Inject
	private Block congratulations;
	
	@Property
	@Persist("flash")
	private Person person;
	
	@Inject
	private Persons persons;
	
	@SetupRender
	public void createObject() {
	    person = new PersonBean();
	}
	
	Object onSuccess() {
		persons.save(person);
		return congratulations;
	}
	
}
